#!/bin/sh

REMOTE_REPO_BASE="https://gitcafe.com/digimobistudio"
REPOS="dms weos elanding"
REPOS_BASE="/home/dms/git-repos"

echo "sync repos: [$REPOS]"

for repo in $REPOS
do
   REPO_PATH="$REPOS_BASE/$repo"
   echo ""
   echo "$repo"
   echo "path: $REPO_PATH"
   
   if [ -d "$REPO_PATH/.git" ]; then
       echo "already have a repo: $repo"
       echo "try update the reop: $repo"
       cd "$REPO_PATH"
       echo "current dir: $PWD"
       echo "git pull origin master master"
       git pull origin master master
       echo "update ok!"
   else
       echo "new repo: $repo"
       if [ -d "$REPO_PATH" ]; then
           rm -rf "$REPO_PATH"
       fi
       
       cd "$REPOS_BASE"
       echo "current dir: $PWD"
       echo "git clone $REMOTE_REPO_BASE/$repo.git"
       git clone "$REMOTE_REPO_BASE/$repo.git"
       echo "clone ok!"
   fi
done
